<template>
	<view class="" >
		<!-- <view class="nav-back">
			<top-heigth :backTitle="backTitle"></top-heigth>
		</view>	 -->
		<view class="nav-back">
			<top-heigth></top-heigth>
			<uv-navbar :fixed="false" bg-color="rgba(0,0,0,0)" title="工时" :safeAreaInsetTop="false">
				<template v-slot:right></template>
				<template v-slot:left>
					<view class="uv-nav-slot"></view>
				</template>
			</uv-navbar>
		</view>
		<view class="content-box">
			<view class="public-box m-t24 back-fff">
				
				<view class="time-box">
					<view :class="num == 1 ? 'time-list2 yue choose' : 'time-list2 yue'" @click="titleChange(1)">
						<view class="xiu-box">今天</view>
					</view>
					<view :class="num == 2 ? 'time-list2 yue choose' : 'time-list2 yue'" @click="titleChange(2)">
						<view class="xiu-box">明天</view>
					</view>
					<view :class="num == 3 ? 'time-list2 yue choose' : 'time-list2 yue'" @click="titleChange(3)">
						<view class="xiu-box">{{getDateTime(2, false)}}</view>
					</view>
				</view>
				
				<!-- <view class="time-all">
					全忙/闲
				</view> -->
				<view class="time-blue">
					过去时间段仅可查看不可修改
				</view>
				
				
				<view class="time-box">
					<template v-for="item in list">
						<template v-if="!item.orderStatus">
							<view class="time-list yue" v-if="item.dayStatus">
								<view class="xiu-box">
									<view>{{item.startTime}}</view>
									<view>可约</view>
								</view>
							</view>
							<view class="time-list xiu" v-else>
								<view class="xiu-box">
									<view>{{item.startTime}}</view>
									<view>休息</view>
								</view>
							</view>
						</template>
						<view class="time-list choose" v-else>
							<view class="xiu-box">
								<view>{{item.startTime}}</view>
								<view>订单</view>
							</view>
						</view>
					</template>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'
	
	export default {
		data() {
			return {
				num:1,
				userInfo: uni.getStorageSync('userInfo'),
				selectDate: this.getDateTime(),
				list: [],
			}
		},
		components: { TopHeigth },
		onLoad() {
			this.listBox(this.getDateTime())
		},
		methods: {
			ssssss(item){
				console.log(item)
			},
			listBox(dateStr){
				uni.$u.http.post('/api/shop/v1_0/tAppStaffTimeConfigRCA/queryTimeStaffConfig',{
					staffId: this.userInfo.id,
					today: dateStr
				}).then((res) => {
					this.list = res.data
				})
			},
			titleChange(n){
				this.num = n
				this.selectDate = this.getDateTime(n - 1)
				this.listBox(this.selectDate)
			},
			getDateTime(day = 0, sign = true){
				// 获取今天的日期
				var today = new Date();
				 
				// 创建一个新的Date对象，并设置日期为今天加一天
				var tomorrow = new Date(today);
				tomorrow.setDate(today.getDate() + day);
				 
				// 获取明天的年、月、日
				var year = tomorrow.getFullYear();
				var month = tomorrow.getMonth() + 1; // 月份从0开始，需要加1
				var day = tomorrow.getDate();
				if(sign){
					return year + '-' + (month > 9 ? month : "0"+month) + '-' + (day > 9 ? day : "0"+day)
				}else{
					return (month > 9 ? month : "0"+month) + '-' + (day > 9 ? day : "0"+day)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	
	.time-top{
		@include flex;
		align-content: space-between;
		width: 100%;
		.title-font{
			width: 33%;
			font-size:28rpx;
			color: #333;
			text-align: center;
			padding-bottom: 16rpx;
		}
		.choose{
			font-weight: bold;
			background: url("/static/image/title-line.png") no-repeat bottom center;
		}
	}
	.time-box{
		
	}
	.time-box{
		@include flex;
		flex-flow: row wrap;
		padding: 20rpx 0rpx;
		.time-list2{
			width:196rpx;
			height:88rpx;
			background:#F8F8F8;
			font-size:28rpx;
			color: #333;
			text-align: center;
			line-height: 88rpx;
			border-radius: 8rpx;
			margin-right: 10rpx;
			/* margin-bottom: 16rpx; */
			border:2rpx solid #F8F8F8;
			&:nth-child(4n+4){
				margin-right: 0;
			}
		}
		.time-list{
			width:149rpx;
			height:108rpx;
			background:#F8F8F8;
			font-size:28rpx;
			color: #333;
			text-align: center;
			line-height: 112rpx;
			border-radius: 8rpx;
			margin-right: 10rpx;
			margin-bottom: 16rpx;
			border:2rpx solid #F8F8F8;
			&:nth-child(4n+4){
				margin-right: 0;
			}
		}
		.xiu{
			color: #999;
			line-height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
		}
		.yue{
			color: #333333;
			line-height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
		}
		.choose{
			color: #27A0FF;
			border:2rpx solid #27A0FF;
			background: rgba(39,160,255,0.15);
		}
	}
	.back-fff{
		background: #fff;
	}
	.time-all{
		width:100%;
		height:88rpx;
		background:#F8F8F8;
		font-size:28rpx;
		color: #333;
		text-align: center;
		line-height: 88rpx;
		border-radius: 8rpx;
		margin-right: 10rpx;
		border:2rpx solid #F8F8F8;
	}
	.time-blue{
		color: #278FFF;
		font-size: 24rpx;
		line-height: 34rpx;
	}
</style>
